package com.woniu.bank.service.impl;

import com.woniu.bank.dto.DscDTO;
import com.woniu.bank.entity.AuditForm;
import com.woniu.bank.mapper.AuditFormMapper;
import com.woniu.bank.service.DscService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author ：lgy
 * @description：TODO
 * @date ：2023/1/5 17:23
 */
@Service
public class DscServiceImpl implements DscService {
    @Autowired
    private AuditFormMapper auditFormMapper;

    /**
     * lgy
     * 审查人审查贷款信息
     * @param dscDTO
     * @return
     */
    @Override
    public int updateDsc(DscDTO dscDTO) {
        AuditForm auditForm = auditFormMapper.selectByPrimaryKey((long) dscDTO.getApprovalStatusId());
        auditForm.setReviewTime(new Date());
        auditForm.setReviewTheSituation(dscDTO.getReviewTheSituation());
        auditForm.setReviewComments(dscDTO.getReviewComments());
        auditForm.setReviewers(dscDTO.getReviewers());
        auditForm.setReviewConclusions(dscDTO.getReviewConclusions());
        if(auditForm.getApprovalStatus().equals("待审查")){
            if(dscDTO.getReviewConclusions().equals("同意")){
                auditForm.setApprovalStatus("待审批");
            }else if(dscDTO.getReviewConclusions().equals("不同意")){
                auditForm.setApprovalStatus("审批不通过");
            }
        }
        return auditFormMapper.updateByPrimaryKeySelective(auditForm);
    }
}
